/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.NoteManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class UpdateAppNote extends AbstractAction
/*    */ {
/* 26 */   private static Logger logger = Logger.getLogger(UpdateNote.class.getName());
/*    */ 
/*    */   public UpdateAppNote(AbstractHttpServlet servlet) {
/* 29 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 35 */     String remark = request.getParameter("remark");
/* 36 */     int noteId = Util.str2Int(request.getParameter("noteId"));
/*    */ 
/* 38 */     User loginUser = super.getLoginUser(request);
/* 39 */     String userId = loginUser.userId;
/*    */ 
/* 41 */     NoteManager manager = new NoteManager();
/*    */     try
/*    */     {
/* 44 */       int result = -1;
/* 45 */       if (loginUser.isAdmin)
/* 46 */         result = manager.updateRemark(noteId, remark, userId);
/*    */       else {
/* 48 */         result = manager.updateRemarkByCreater(noteId, remark, userId);
/*    */       }
/* 50 */       if (result > 0) {
/* 51 */         response.setContentType("text/html;charset=utf-8");
/* 52 */         PrintWriter out = response.getWriter();
/* 53 */         JSONObject jsonObject = new JSONObject();
/* 54 */         jsonObject.put("error", "0");
/* 55 */         jsonObject.put("result", Integer.valueOf(result));
/* 56 */         out.println(jsonObject);
/* 57 */         out.flush();
/* 58 */         out.close();
/* 59 */         return;
/*    */       }
/*    */     } catch (DBException e) {
/* 62 */       logger.warn("update note failed", e);
/*    */     } catch (SQLException e) {
/* 64 */       logger.warn("update note failed", e);
/*    */     }
/* 66 */     super.showErrorMessage(response, "修改备注失败，请稍后重试");
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateAppNote
 * JD-Core Version:    0.6.1
 */